package com.douwong.student.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.douwong.student.R;
import com.douwong.student.model.ClassFileRecordBean;
import com.douwong.student.model.ClassNoteItem;
import com.douwong.student.view.MyGridView;

import java.util.ArrayList;
import java.util.List;

public class ClassFileRecordAdapter extends BaseAdapter {


	private List<ClassFileRecordBean> mClassFileRecordBeen;
	private Context context;

	public ClassFileRecordAdapter(List<ClassFileRecordBean> classFileRecordBeen, Context context) {
		mClassFileRecordBeen = classFileRecordBeen;
		this.context = context;
	}
	public void setData(List<ClassFileRecordBean> classFileRecordBeen){
		mClassFileRecordBeen = classFileRecordBeen;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mClassFileRecordBeen.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if (convertView == null) {
			holder = new Holder();
			convertView = LayoutInflater.from(context).inflate(R.layout.class_file_item, null);
			holder.time = (TextView) convertView.findViewById(R.id.time);
			holder.pic_gridview = (MyGridView) convertView.findViewById(R.id.pic_gridview);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		ArrayList<ClassNoteItem> temp = new ArrayList<ClassNoteItem>();
		if (mClassFileRecordBeen.size() > 0) {
			temp.addAll(mClassFileRecordBeen.get(position).getList());
			holder.time.setText(mClassFileRecordBeen.get(position).getCreateTime().substring(0, 10));
		}
		ClassFileRecordInnerAdapter adapter = new ClassFileRecordInnerAdapter(temp, context);
		holder.pic_gridview.setAdapter(adapter);
		return convertView;
	}

	class Holder {
		TextView time;
		MyGridView pic_gridview;
	}

}
